package il.ac.technion.cs236700.utils;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.PrintWriter;

/**
 * A class through which all logging messages go.
 */
class Logger {
	final PrintWriter wr;
	private int line = 0;

	public int line() {
		return line;
	}

	public Logger(File f) throws FileNotFoundException {
		OutputStream os = new FileOutputStream(f);
		wr = new PrintWriter(os, true);
	}

	public Logger(PrintStream out) {
		wr = new PrintWriter(out, true);
	}

	public void println() {
		println(null);
	}

	public void println(String s) {
		wr.print("[" + ++line + "] ");
		wr.flush();
		if (s != null)
			wr.println(s);
	}

	public void flush() {
		wr.flush();
	}
}